<template>
  <el-dialog title="调查问卷查询" :close-on-click-modal="false" :visible.sync="visible" fullscreen center append-to-body>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-table :data="dataList" height="calc(100vh - 215px)" ref="singleTable" border v-loading="dataListLoading">
      <el-table-column type="index" width="50">
        <template slot-scope="scope">
          <el-radio v-model="probleId" :label="scope.row.id" style="position: relative;left: 6px;top:-2px;" @change="checkitem(scope.row)">&nbsp;</el-radio>
        </template>
      </el-table-column>
      <el-table-column prop="title" label="问卷调查标题"></el-table-column>
      <el-table-column prop="rewardType" label="奖励类型">
        <template slot-scope="scope">
          <span v-if="scope.row.rewardType == '1'">无奖励</span>
          <span v-if="scope.row.rewardType == '2'">积分奖励</span>
        </template>
      </el-table-column>
    </el-table>
    <div class="avue-crud__pagination">
      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next">
      </el-pagination>
    </div>
  </el-dialog>
</template>

<script>
  import {filterParams} from '@/util/tools'
  import { fetchWxQuestionnaireList } from '@/api/mp/wxquestionnaire'
  export default {
    data () {
      return {
        visible: false,
        probleId: '',
        list: [],
        dataList: [],
        dataListLoading: false,
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
      }
    },
    methods: {
      init(list) {
        this.visible = true
        this.probleId = ''
        this.getDataListt()
      },
      getDataListt() {
        fetchWxQuestionnaireList({ current: this.pageIndex, size: this.pageSize }).then(result => {
          this.dataList = result.data.data.records
        })
      },
      sizeChangeHandle(val){
        this.pageIndex = 1
        this.pageSize = val
        this.getDataListt()
      },
      currentChangeHandle(val){
        this.pageIndex = val
        this.getDataListt()
      },
      // 选择品种
      checkitem(val) {
        this.visible = false
        this.$emit('refreshData',val)
      },
    }
  }
</script>

<style>
</style>
